<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="./css/index.css">
  <title>Document</title>
  <style>
    #main {
      width: 800px;
      height: 600px;
      margin: auto;
    }
  </style>
</head>

<body>
  <div id="app">
      <div class="container">
        <div id="main"></div>
        <div class="button_fa">
            <button class="d-button mr-20" @click="downloadPdf">下载PDF</button>
            <button class="d-button danger" @click="close">关闭页面</button>
        </div>
      </div>
  </div>
  <script src="js/jspdf.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
  <script src="js/echarts.min.js"></script>
  <script src="js/Dcharts.js"></script>
  <script src="js/common.js"></script>
  <script>
    let d = "";
    const vue = new Vue({
      el: '#app',
      data: {
      },
      mounted() {
        d = new Dcharts();
        try {
            d.drawPie("main",  this.getUrldata("data"),"头部数据")
        } catch (error) {
          console.log(error);
        }
       
      },
    //   http://127.0.0.1:5500/DemoPie.html?data={%22%E8%A5%BF%E5%87%89%22:%221547%22,%22%E7%9B%8A%E5%B7%9E%22:%22510%22,%22%E5%85%96%E5%B7%9E%22:%22890%22,%22%E5%B9%BD%E5%B7%9E%22:%22420%22,%22%E8%8D%86%E5%B7%9E%22:%22300%22}
      methods:{
          getUrldata(name){
            return utils.getUrldata(name)
          },
          downloadPdf(){
                let doc = new jsPDF('l', 'px', 'a4');
                // let picBase64Info = d.getDataURL()
                let echarts = document.querySelector("canvas")
                console.log(echarts.offsetWidth);
                console.log(doc);
                let dataurl = echarts.toDataURL()
                doc.addImage(dataurl,'PNG',100,100)
                doc.save('Test.pdf');
          },
          close(){
            　 window.location.href="about:blank";
              window.close();
          }
      }
    });
  </script>
</body>

</html>